package com.moxi.service;

import com.moxi.model.NewsCategory;
import com.moxi.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface UserService {
    @Select({
            "<script>",
            "SELECT * FROM admin",
            "WHERE state = 0",
            "<when test='userName!=null'>",
            "AND userName LIKE '%' #{userName} '%'",
            "</when>",
            "</script>"
    })
    List<User> findAllUserLikeByNameAndByPage(User user);

    @Select("select count(*) from admin where state=0")
    int count(User user);

    @Select("select * from admin where id=#{id}")
    User selectById(User user);

    @Delete("delete from admin where id=#{id}")
    boolean deleteUser(User user);

    @Update("update admin set userName=#{userName},password=#{password},realName=#{realName},age=#{age},phoneNumber=#{phoneNumber},updateDate=#{updateDate} where id=#{id}")
    boolean updateUser(User user);

    @Insert("insert into admin (userName,password,realName,age,phoneNumber,addDate) values(#{userName},#{password},#{realName},#{age},#{phoneNumber},#{addDate})")
    boolean insertUser(User user);
}
